<?php

namespace App\Repositories\Users;

use Illuminate\Support\Facades\Auth;
use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Users\UsersRepository;
use App\Models\Users\Users;
use App\Validators\Users\UsersValidator;

/**
 * Class UsersRepositoryEloquent.
 *
 * @package namespace App\Repositories\Users;
 */
class UsersRepositoryEloquent extends BaseRepository implements UsersRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Users::class;
    }

    /**
    * Specify Validator class name
    *
    * @return mixed
    */
    public function validator()
    {

        return UsersValidator::class;
    }


    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

    /**
     * 获取会员等级
     * @author Min
     * @param $user_id
     * @return bool
     */
    public function getUserRankByUid($user_id){
        $where = [
            'user_id' => $user_id
        ];

        $res = $this->findWhere($where)->first();

        if(!$res){
            return false;
        }

        return $res->user_rank;

    }
    
}
